package onlineLanguageQuizSubmission

import org.springframework.cloud.contract.spec.Contract

Contract.make {
    request {
        method("POST")
        url("/api/v3/onlineLanguageSubmission")
        headers {
            contentType(applicationJsonUtf8())
        }
        body("""
            {
                "id":1,
                "assignmentId":1,
                "studentId":1,
                "language":"java",
                "userAnswerCode":"adasasd"               
            }
        """)
        bodyMatchers {
            jsonPath('$.id', byRegex(number()))
            jsonPath('$.assignmentId', byRegex(number()))
            jsonPath('$.studentId', byRegex(number()))
            jsonPath('$.language', byRegex("[\\s\\S]+"))
            jsonPath('$.userAnswerCode', byRegex("[\\s\\S]+"))
        }
    }
    response {
        status(201)
        headers {
            contentType(applicationJsonUtf8())
        }
        body("""
            {
                "id":1,
                "assignmentId":1,
                "quizId":1,
                "userId":1,
                "userAnswer":"asdas",
                "submitTime":12345678,
                "status":null,
                "result":null,
                "answerLanguage":"java",
                "buildNumber":null
            }
        """)
        bodyMatchers {
            jsonPath('$.id', byRegex(number()))
            jsonPath('$.assignmentId', byRegex(number()))
            jsonPath('$.quizId', byRegex(number()))
            jsonPath('$.userId', byRegex(number()))
            jsonPath('$.userAnswer', byRegex("[\\s\\S]+"))
            jsonPath('$.submitTime', byRegex("[\\s\\S]+"))
            jsonPath('$.answerLanguage', byRegex("[\\s\\S]+"))
        }
    }
}
